home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / MOUSE_CL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-22  |  3.0 KB  |  100 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <MINTBIND.H>
  9. #include <OSBIND.H>
  10. #include <memory.h>
  11. #include "K_DEFS.H"
  12. #include "KERNAL.H"
  13. #include "XA_DEFS.H"
  14. #include "XA_TYPES.H"
  15. #include "XA_GLOBL.H"
  16. #include "MOUSE_CL.H"
  17. #include "EVNT_BTN.H"
  18. #include "C_WINDOW.H"
  19. #include "EVNT_MUL.H"
  20. #include "std_widg.h"
  21.  
  22. /*
  23.     Mouse button click handler 
  24.     - MOUSESRV sever process passes us click events
  25. */
  26.  
  27. /* The real button click handler is here :) */
  28. short XA_button_event(MOOSE_BUTTON_DATA *md)
  29. {
  30.     XA_CLIENT *client;
  31.     XA_WINDOW *w;
  32.     short kstate;
  33.     unsigned long retv=XA_OK;
  34.     short target_app=0;
  35.     
  36.     DIAGS(("MOUSE_CLICK EVENT: \n   loc=(%d,%d), state=%d, count=%d\n",md->x,md->y,md->state, md->clicks));
  37.  
  38.     w=wind_find(md->x, md->y);        /* Try for a window */
  39.     target_app=w->owner;
  40.     
  41.     if ((mouse_lock==0)&&(update_lock==0))        /* if nothing is locked, do a widgets test first */
  42.     {
  43.         DIAGS(("calling do_widgets (wind owner=%d)\n",w->owner));
  44.         if (do_widgets(w,md))
  45.             return FALSE;    /* Process window widgets */
  46.     }else{
  47.         if (mouse_lock)                    /* Mouse is locked - clicks go to owner of mouse */
  48.         {
  49.             target_app=mouse_lock;
  50.             DIAGS(("mouse is locked by %d\n",mouse_lock));
  51.         }else{
  52.             if (update_lock)            /* Screen is locked - clicks go to owner of screen */
  53.             {
  54.                 target_app=update_lock;
  55.                 DIAGS(("screen is locked by %d\n",update_lock));
  56.             }
  57.         }
  58.         if ((w->owner==target_app)&&(w->active_widgets&NO_WORK))
  59.         {
  60.             if (do_widgets(w,md))
  61.                 return FALSE;    /* Process window widgets for no-work windows (this'll deal with alerts) */
  62.         }
  63.     }
  64.  
  65.     Psemaphore(2,CLIENTS_SEMAPHORE,-1L);
  66.  
  67.     client=Pid2Client(target_app);
  68.  
  69.     if (client->waiting_for&XAWAIT_BUTTON)    /* If the client owning was waiting for a button event, send it */
  70.     {                                        /* - otherwise forget it, 'coz we don't want delayed clicks (they are confusing to the user [ie. me] ) */
  71.         vq_key_s(V_handle, &kstate);        /* get the current keyboard state */
  72.         if ((client->waiting_pb)&&(client->clnt_pipe_rd))
  73.         {
  74.             if (client->waiting_for&XAWAIT_MULTI)            /* If the client is waiting on a multi, the response is  */
  75.             {                                                /* slightly different to the evnt_button() response. */
  76.                 client->waiting_pb->intout[0]=MU_BUTTON;
  77.                 client->waiting_pb->intout[1]=md->x;
  78.                 client->waiting_pb->intout[2]=md->y;
  79.                 client->waiting_pb->intout[3]=md->state;
  80.                 client->waiting_pb->intout[4]=kstate;
  81.                 client->waiting_pb->intout[6]=md->clicks;
  82.                 cancel_evnt_multi(target_app);
  83.             }else{
  84.                 client->waiting_pb->intout[0]=md->state;
  85.                 client->waiting_pb->intout[1]=md->x;
  86.                 client->waiting_pb->intout[2]=md->y;
  87.                 client->waiting_pb->intout[3]=md->clicks;
  88.                 client->waiting_pb->intout[4]=kstate;
  89.                 client->waiting_for=0;            /* Now client isn't waiting for anything */
  90.             }
  91.             Fwrite(client->clnt_pipe_wr,sizeof(unsigned long),&retv);    /* Write success to clients reply pipe to unblock the process */
  92.         }
  93.     }
  94.  
  95.     Psemaphore(3,CLIENTS_SEMAPHORE,0L);
  96.  
  97.     return FALSE;
  98. }
  99.  
  100.